home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994 Marc Parmet.
- * This file is part of the Macintosh port of GNU Emacs.
- *
- * GNU Emacs is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
- #include <Types.h>
- #include <Processes.h>
- #include <MixedMode.h>
- #include "emacs-version.h"
- #include "kbd-patch-data.h"
-
- pascal long
- emacs_KeyTrans_patch(Ptr transData,short keyCode,long *state)
- {
- int i,size;
- Boolean same;
- short err,modifiers;
- ProcessSerialNumber front_psn;
- struct keyboard_patch_vector *v;
- struct keyboard_patch_data *kbpd;
-
- kbpd = (struct keyboard_patch_data *)PATCH_MAGIC;
-
- if (kbpd->emacs_psn.lowLongOfPSN != 0 || kbpd->emacs_psn.highLongOfPSN != 0) {
- err = GetFrontProcess(&front_psn);
- if (!err) {
- err = SameProcess(&kbpd->emacs_psn,&front_psn,&same);
- if (!err && same) {
- v = MODIFIER_XVECTOR(*kbpd->v);
- if (v != 0L) {
- modifiers = keyCode & MODIFIER_KEYS;
- if (modifiers != 0) {
- /* Clear the mark bit, so this doesn't crash during gc. */
- size = v->size & 0x7fffffff;
- for (i = 0; i<size; ++i) {
- if (v->contents[i].typed == modifiers) {
- keyCode &= ~MODIFIER_KEYS;
- keyCode |= v->contents[i].denoted &
- ~(controlKey | metaKey);
- break;
- }
- }
- }
- }
- }
- }
- }
-
- #if defined(powerc)
- return CallUniversalProc(kbpd->original,uppKeyTransProcInfo,
- transData,keyCode,state);
- #else
- return (*(KeyTransProcPtr)kbpd->original)(transData,keyCode,state);
- #endif
- }
-